import Collection from './base'

export const Projects = new Collection({
  name: 'projects',
  publish: [
    {
      name: 'projects',
      callback () {
        return Projects.find({}, {
          fields: {
            name: true
          }
        })
      }
    }, {
      name: 'projects.user',
      callback (userId) {
        return Projects.find({creator: userId})
      }
    }
  ],
  schema: {
    name: { type: String },
    describe: { type: String, optional: true },
    creator: { type: String },
    createDate: { type: Date }
  }
})
